import time

from curl_cffi import requests
import scrapy

headers = {
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "priority": "u=1, i",
    "referer": "https://www.zhipin.com/web/geek/jobs",
    "sec-ch-ua": "\"Chromium\";v=\"142\", \"Microsoft Edge\";v=\"142\", \"Not_A Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "token": "NGRr38va4hucHsYn",
    "traceid": "F-aaf8eaHEQgpzcLsi",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0",
    "x-requested-with": "XMLHttpRequest",
    "zp_token": "V2R98iE-L83VxoVtRuyR4aKiiy7DrXzC8~|R98iE-L83VxoVtRuyR4aKiiy7DrSwi4~"
}
cookies = {
    "__zp_seo_uuid__": "9be2fb69-28a8-47ef-bf20-e8bcbf19162a",
    "Hm_lvt_194df3105ad7148dcf2b98a91b5e727a": "1762507887",
    "HMACCOUNT": "AC4951CBF00AD43B",
    "__g": "sem_bingpc",
    "__l": "r=https%3A%2F%2Fcn.bing.com%2F&l=%2Fwww.zhipin.com%2Fsem%2F10.html%3F_ts%3D1762507879794%26sid%3Dsem_bingpc%26qudao%3Dbing_pc_H120003UY5%26plan%3DBOSS-%25E5%25BF%2585%25E5%25BA%2594-%25E5%2593%2581%25E7%2589%258C%26unit%3D%25E7%25B2%25BE%25E5%2587%2586%26keyword%3Dboss%25E7%259B%25B4%25E8%2581%2598%26msclkid%3D8a00f70e8a041bb6251e9e0336618e51&g=%2Fwww.zhipin.com%2Fsem%2F10.html%3F_ts%3D1762507879794%26sid%3Dsem_bingpc%26qudao%3Dbing_pc_H120003UY5%26plan%3DBOSS-%25E5%25BF%2585%25E5%25BA%2594-%25E5%2593%2581%25E7%2589%258C%26unit%3D%25E7%25B2%25BE%25E5%2587%2586%26keyword%3Dboss%25E7%259B%25B4%25E8%2581%2598%26msclkid%3D8a00f70e8a041bb6251e9e0336618e51&s=3&friend_source=0",
    "wt2": "DOch_B03f2U38er5Y_Dt1i996UVHaL1S9qgp-56QbJg0aW6D-hBXsbgejSty6Cd3rrJYqHOjE2XQ7xAcKiB1UeQ~~",
    "wbg": "0",
    "zp_at": "VkY1S0_gO3nufz4-wfFu-BaWpUEWlYhbC0whfO4J8X4~",
    "ab_guid": "6b6b35d7-c013-4d96-87c3-b231869a00fb",
    "Hm_lpvt_194df3105ad7148dcf2b98a91b5e727a": "1762507937",
    "__zp_stoken__": "7226fw4Z0wqlrPRUYDA1jU2RNZ3HCrEpZdWdUZnlXwoTCsk%2FCv3PCtltOw4vCrnPDgMK5wr3Cs8KlV8SLwr%2FCp8K4wrnDiMSFwq7Cj8Kaw73DgcKPwp%2FDvMKjxIHCs8O5wp%2FEgcK8wpbCvMOlwr3Dt8KMw6zCqMO6w4DFi8K4w7DCs8O9wq7EhMKKxYHCnsOPwrrFiMKdxKTEg8OawqbErcKaxYPEh8SZwq3Dj8WxxJ5Jxr7EjcSAwrnCpEUtGw0QGBgTFRgQEAYUChISEBIbExMSEA0VFUg1w7zDgCFCQ0FELkxOVw5KX2hMXU4RWk9RREtjYGtrSzc8RERHw4fCq8OLwrTCucKiw4PCtMK2wqDCusO8RDxHOcK9RDs0w4B2GMOFVg3CvUkYw4fCpWPDhUgbw4llMcKQw6HDgMK1MEJFwrnEvzlFIUc9RT9CQERFRTFAFsOUXS7ClcOWw4XCiTI5HT1FQktDRUVCRT0%2FMUJIIzdFRylBFQwVDg0yNsOLwpTCvMOgRUI%3D",
    "bst": "V2R98iE-L83VxoVtRuyR4aKiiy7DrXzC8~|R98iE-L83VxoVtRuyR4aKiiy7DrSwi4~",
    "__c": "1762507879",
    "__a": "70421593.1762507879..1762507879.5.1.5.5"
}
url = "https://www.zhipin.com/wapi/zpgeek/pc/recommend/job/list.json"
params = {
    "page": "1",
    "pageSize": "15",
    "city": "101180100",
    "encryptExpectId": "",
    "mixExpectType": "",
    "expectInfo": "",
    "jobType": "",
    "salary": "",
    "experience": "",
    "degree": "",
    "industry": "",
    "scale": "",
    "_": f"{int(time.time()*1000)}"
}

class Boss(scrapy.Spider):
    name = "boss"
    def start_requests(self):
        for i in range(1, 10):
            yield scrapy.FormRequest(url, callback=self.parse,
                 method="POST",
                 cookies=cookies,
                 headers=headers,
                 formdata=params
                                 )
    def parse(self, response):
        print(response.status)
        print(response.json())
